<?php
namespace App\BaseExt;
use Symfony\Component\HttpFoundation\Request;

/**
 * PicUpload Class
 */
class MyPhpWord {

    public function replace1($path,$find="",$val="")
    {
        require_once '../BaseExt/PHPWord/Template.php';

        $PHPWord = new PHPWord_Template("./admin/222.doc");
//        $PHPWord->setValue('Name', 'PHP54技术博客');
        $PHPWord->setValue('__NAME__', 'PHP54技术博客');

//        $PHPWord->setImg('Image',['src' => 'public/img/logo.png']);

        $PHPWord->save('./admin/Template1.docx');
    }


    public $PHPWord;
    public function open($path)
    {
        require_once '../BaseExt/PHPWord/Template.php';
        $this->PHPWord = new \PHPWord_Template(".$path");
        return $this;
    }

    public function replace($find="",$val="")
    {
        $this->PHPWord->setValue($find, $val);
        return $this;
    }

    public function save($path)
    {
        $this->PHPWord->save(".$path");
    }
}
